package com.example.siyun.controller.microcontroller;

import com.example.siyun.pojo.MicroAudit;
import com.example.siyun.service.microservice.MicroAuditService;
import com.example.siyun.util.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description: 微圈审核的控制成
 */
@Slf4j
@RestController
public class MicroAuditController {
    @Autowired
    private MicroAuditService microAuditService;
    /**
     * 添加微圈审核记录
     */
    @RequestMapping("/primary/addmicroaudit")
    public PageResult addMicroAudit(MicroAudit microaudit, HttpSession session){
        log.info("添加微圈审核记录");
        Timestamp time = new Timestamp(new Date().getTime());
        microaudit.setAudittime(time);
        String auditname = (String) session.getAttribute("loginname");
        microaudit.setAuditors(auditname);
        System.out.println(microaudit);
        PageResult pageResult=new PageResult();
        if(microaudit.getAuditresults().equals("审核通过")){
            int shstatus=1;
            microAuditService.courseAuditAdd(microaudit);
            microAuditService.microAppStatusById(shstatus,microaudit.getAid());
        } else if (microaudit.getAuditresults().equals("审核不通过")) {
            int shstatus=2;
            microAuditService.microAppStatusById(shstatus,microaudit.getAid());
            microAuditService.courseAuditAdd(microaudit);
        }
//        pageResult.setStatus(200);
        log.info("添加微圈审核记录成功");
        return pageResult;
    }
}
